package com.coolingme.chain;

import lombok.Data;

/**
 * 链式建造者
 *
 * @author wangyue
 * @date 2020/9/30 11:00
 */
public class CourseChainBuilder {

    /**
     * 将Course变为CourseBuilder的内部类
     *
     * @author wangyue
     * @date 2020/9/30 11:01
     */
    @Data
    public class Course {

        private String name;

        private String video;

        private String note;

    }

    private Course course = new Course();

    /**
     * 构造步骤，每完成一个，返回this
     *
     * @param name 姓名
     * @return this
     */
    public CourseChainBuilder addName(String name) {
        this.course.setName(name);
        return this;
    }

    public CourseChainBuilder addVideo(String video) {
        this.course.setVideo(video);
        return this;
    }

    public CourseChainBuilder addNote(String note) {
        this.course.setNote(note);
        return this;
    }

    public Course build() {
        return this.course;
    }


}
